package com.stanford.ml.naivebayes;

/**
 * Data container for user attributes
 * 
 * @author Fatih Sunor
 * 
 */
public class Attribute {

	private String _name;
	private Object _value;

	/**
	 * Constructor to initialize the fields
	 * 
	 * @param name
	 *            of the attribute
	 * @param value
	 *            of the attribute
	 */
	public Attribute(String name, Object value) {
		_name = name;
		_value = value;
	}

	/**
	 * Return name
	 * 
	 * @return name
	 */
	public String getName() {
		return _name;
	}

	/**
	 * Return value object
	 * 
	 * @return value
	 */
	public Object getValue() {
		return _value;
	}

	public boolean equals(Object obj) {
		final Attribute other = (Attribute) obj;
		if (obj == null) {
			return false;
		}

		if (getClass() != obj.getClass()) {
			return false;
		}
		if (this == obj) {
			return true;
		}
		if (_value == null) {
			if (other._value != null) {
				return false;
			}
		} else if (!_value.equals(other._value)) {
			return false;
		}
		return true;
	}
}
